{include file="Public/header"/}
<!--HEADER-->

<!--找回密码-->
<div class="container vipmodifypwd">
    <div class="row">
        <div class="col-md-12">
            <div class="card mb-4 box-shadow">
                <div class="card-body row">
                    <div class="col-md-6">
                        <img src="/static/home/images/bg_login_side.jpg" alt=""  class="img-fluid">
                    </div>
                    <div class="col-md-6 mb-4">
                        <div class="col-md-12 mb-4 bd1">
                            <h2>找回密码</h2>
                        </div>
                        <form id="lostpwForm" method="post" class="form-horizontal" action="/index/Modifypwd/usersave" novalidate="novalidate" >

                            <div class="form-group row">
                                <label class="col-md-3 sm-text-right control-label" for="lostpwUserName"><b class="redFont">*</b>&nbsp;用户名：</label>
                                <div class="col-md-9 has-error has-feedback">
                                    <input type="text" class="form-control" id="lostpwUserName" name="mobile" placeholder="请输入手机号" aria-required="true" aria-describedby="firstname1-error" aria-invalid="true">
                                    <span class="glyphicon glyphicon-remove form-control-feedback" id='sj'></span>
                                    <label id="lostpwUserName-error" class="error" for="lostpwUserName"></label>
                                </div>
                            </div>

                            <div class="form-group row">
                                <label for="lostpwSmsCode" class="col-md-3 control-label"><b class="redFont">*</b>&nbsp;手机验证码：</label>
                                <div class="col-md-9">
                                    <div class="input-group">
                                        <!--<span class="input-group-addon"><span class="glyphicon glyphicon-qrcode"></span></span>-->
                                        <input type="text" class="form-control" name="code" id="lostpwSmsCode" placeholder="请输入验证码"value="">
                                        <div class="input-group-btn">
                                            <input type="button" class="btn btn-success" id="lostpwBtnSmsCode" value="免费获取验证码"/>
                                        </div>
                                    </div>
                                    <span class="glyphicon glyphicon-remove form-control-feedback" id='yz'></span>
                                    <label id="lostpwSmsCode-error" class="error" for="lostpwSmsCode"></label>
                                </div>
                            </div>

                            <div class="form-group row">
                                <label class="col-md-3 control-label" for="lostpwUserPassword"><b class="redFont">*</b>&nbsp;密码：</label>
                                <div class="col-md-9 has-error has-feedback">
                                    <input type="password" class="form-control" id="lostpwUserPassword" name="pwd" placeholder="请输入密码" aria-required="true" aria-describedby="firstname1-error" aria-invalid="true">
                                    <span class="glyphicon glyphicon-remove form-control-feedback" id="pwd"></span>
                                    <label id="lostpwUserPassword-error" class="error" for="lostpwUserPassword"></label>
                                </div>
                            </div>

                            <div class="form-group row">
                                <label class="col-md-3 control-label" for="lostpwUserConfirmPassword"><b class="redFont">*</b>&nbsp;确认密码：</label>
                                <div class="col-md-9 has-error has-feedback">
                                    <input type="password" class="form-control" id="lostpwUserConfirmPassword" name="pwds" placeholder="请再次输入密码" aria-required="true" aria-describedby="firstname1-error" aria-invalid="true">
                                    <span class="glyphicon glyphicon-remove form-control-feedback" id="pwds"></span>
                                    <label id="lostpwUserConfirmPassword-error" class="error" for="lostpwUserConfirmPassword"></label>
                                </div>
                            </div>

                            <div class="form-group row">
                                <div class="col">
                                    <button type="submit" class="btn btn-success btn-block" name="signup1" value="找回密码">找回密码</button>
                                </div>
                            </div>
                            <p style="padding:10px 5px;"><b class="fontRed">*注：</b>尊敬的客户你好，为保护客户的隐私，公司决定采用身份证号码注册，不再保留客户的手机号码，所以客户忘记密码将无法自己重置，需要联系公司客服重置密码。忘记密码客户请拨打400-071-0176联系事宜。</p>
                        </form>


                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<br/><br/><br/><br/><br/><br/>


{include file="Public/footer"/}

<script>
flag=false;flagc=false;fapwd=false;fapwds=false;
    $("#lostpwBtnSmsCode").click(function () {
        if($("#lostpwUserName").val() != ""){
            var mobile = $("#lostpwUserName").val();
            if (mobile.match(/(^1[3|4|5|6|7|8|9]\d{9}$)|(^09\d{8}$)/) != null) {
                $.ajax({
                    url: "/index/Modifypwd/registersendMsg",
                    type: "POST",
                    data: {
                        mobile : mobile,
                    },
                    success: function (data) {
                        if(data['msg']=='success'){
                            alert('验证码发送成功');
                        }else{
                            $("#sj").html(data['msg']).css('color','red');
                        }
                    }
                });  
                regSettime(this); 
            }else{
                $("#sj").html('账号格式错误').css('color','red');
            }
        }else{
            $("#sj").html('手机号不能为空').css('color','red');
        }
    });
    var regCount = 60;
    function regSettime(obj) {
        if (regCount == 0) {
            obj.removeAttribute("disabled");
            obj.value = "免费获取验证码";
            regCount = 60;
            return;
        } else {
            obj.setAttribute("disabled", true);
            obj.value = "重新发送(" + regCount + ")";
            regCount--;
        }
        setTimeout(function () {
                regSettime(obj)
            }
            , 1000)
    }

    $("#lostpwSmsCode").focus(function(){
        $("#yz").html('');
    }).blur(function(){
        var code = $("#lostpwSmsCode").val();
        var mobile = $("#lostpwUserName").val();
        if(!mobile){
            $("#sj").html('手机号不能为空').css("color",'red');
            flag=false;
        }else{
            $.ajax({
                url : '/index/Modifypwd/codeVerification',
                type : 'POST',
                data : {
                    mobile : $("#lostpwUserName").val(),
                    code : code,
                },
                success : function(data){
                    if(data['msg']=='success'){
                        flag=true;
                    }else{
                        $("#yz").html('验证码验证错误').css('color','red');
                        flag=false;
                    }
                }
            }) 
        }
    });

    $("#lostpwUserPassword").focus(function(){
        $("#pwd").html('');
    }).blur(function(){
        var pwd = $("#lostpwUserPassword").val();
        if(pwd!=null){
            if(pwd.match(/^[0-9a-zA-Z]+$/) == null){
                $("#pwd").html('密码格式错误').css('color','red');
                fapwd = false;
            }else{
                 if(pwd.length >= 6 && pwd.length <= 15){
                    fapwd = true;
                }else{
                    $("#pwd").html('密码格式错误').css('color','red');
                    fapwd = false;
                }
            }
        }else{
            $("#pwd").html('密码不能为空').css('color','red');
            fapwd = false;
        }
    });
    $("#lostpwUserConfirmPassword").focus(function(){
        $("#pwds").html('');
    }).blur(function(){
        var pwds = $("#lostpwUserConfirmPassword").val();
        var pwd  = $("#lostpwUserPassword").val();
        if(pwd!=pwds){
            $("#pwds").html('密码不一致').css('color','red');
            fapwds = false;
        }else{
            fapwds = true;
        }
    });

    $("form").submit(function(){
        if (!flag||!fapwd||!fapwds){
            return false;
        }else{
            return true;
        }   
    });
</script>